<?php
namespace App\Http\Controllers;
use App\AdminUser;
use App\Customer;
use App\Business;
use App\contract;
use App\Task;
use Charts;

class HomeController extends Controller{

    public function index()
    {

        date_default_timezone_set('PRC');
        $time=date('Y-m-d h:i:s', time());   // 2016-12-31 05:07:05
        $start=date('Y-m-01 h:i:s',strtotime($time));//获取指定月份的第一天
        $end=date('Y-m-t h:i:s',strtotime($time)); //获取指定月份的最后一天
        $task_count= Task::whereBetween('created_at',[$start,$end])->count();
        $customer_count= Customer::whereBetween('created_at',[$start,$end])->count();
        $business_count= Business::whereBetween('created_at',[$start,$end])->count();
        $contract_count=contract::whereBetween('created_at',[$start,$end])->count();
        return view('admin.home.index',compact('task_count','customer_count','business_count','contract_count'));
        //return view('admin.home.index', ['chart' => $chart]);
    }
}